from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from redis import StrictRedis
from flask_wtf.csrf import CSRFProtect


class Config(object):
    """配置文件的加载"""
    DEBUG = True
    SECRET_KEY = 'DDEWDWEdscdcdcdededwe'
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information_28"
    SQLALCHEMY_TRACK_MODIFICATIONS = False   # 提高性能不追踪
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

app = Flask(__name__)
app.config.from_object(Config)
# mysql的连接
db = SQLAlchemy(app)
# 开启csrf保护
CSRFProtect(app)
# redis的连接
redis_store = StrictRedis(host=Config.REDIS_HOST, port=Config.REDIS_PORT)


@app.route('/')
def index():
    redis_store.set('name', 'zs')
    return 'index'

if __name__ == '__main__':
    app.run()
